package com.qf.smsplatform.strategy.service.api;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;
import java.util.Set;

@FeignClient(value = "SMS-PLATFORM-CACHE")
public interface CacheService {

    @RequestMapping(value = "/cache/hget/{key}/{field}", method = RequestMethod.GET)
    String hGet(@PathVariable("key") String key, @PathVariable("field") String field);
    // RequestParam  value () param... 0...

    // 获取key-value结构数据,value类型为String
    @RequestMapping(value = "/cache/get/{key}", method = RequestMethod.GET)
    String get(@PathVariable("key") String key);

    // 添加数据到set结构中
    @RequestMapping(value = "/cache/sadd")
    boolean sadd(@RequestParam("key") String key, @RequestParam("value") String... value);

    // set集合的交集操作
    @RequestMapping(value = "/cache/inter")
    Set<Object> intersect(@RequestParam String key, @RequestParam String otherKey);

    // 获取set集合数据
    @RequestMapping(value = "/cache/members/{key}")
    Set<String> members(@PathVariable String key);

    @RequestMapping(value = "/cache/zrangebyscore")
    Set<Object> zRangeByScore(@RequestParam String key,@RequestParam Double min,@RequestParam Double max);

    @RequestMapping(value = "/cache/keys/{pattern}")
    Set<String> keys(@PathVariable(value = "pattern") String pattern);

    @RequestMapping(value = "/cache/hmget/{key}", method = RequestMethod.GET)
    Map hMGet(@PathVariable("key") String key);

    // hincr
    @RequestMapping(value = "/cache/hincr")
    Long hincr(@RequestParam String key,@RequestParam String field,@RequestParam Long delta);

    @RequestMapping(value = "/cache/incr", method = RequestMethod.GET)
    Long incr(@RequestParam("key") String key, @RequestParam("delta") Long delta);

}
